﻿Imports System.Data
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Partial Class Consultas_EgresadosXPrograma_EgrexProg
    Inherits PaginaComun

    Sub Mostrar_Listado()
       
    End Sub

    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        Select Case e.CommandName
            Case "Listado"
                Dim index As Integer = Convert.ToInt32(e.CommandArgument)
                GridView1.SelectedIndex = index
                Dim obj As New Egresados
                Dim dt As DataTable = obj.GetListaEgresados(GridView1.DataKeys(index).Values(0).ToString(), GridView1.DataKeys(index).Values(1).ToString())
                HF1.Value = GridView1.DataKeys(index).Values(0).ToString()
                HF2.Value = GridView1.DataKeys(index).Values(1).ToString()
                HF3.Value = GridView1.DataKeys(index).Values(2).ToString()
                GridView2.DataSource = dt
                GridView2.DataBind()
                Me.MultiView1.ActiveViewIndex = 1
        End Select
        
    End Sub

    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        Me.MultiView1.ActiveViewIndex = 0
    End Sub

    Protected Sub LinkButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim obj As New Egresados
        Dim dt As DataTable = obj.GetListaEgresados(HF1.Value, HF2.Value)
        Dim rpt As New ReportDocument
        Dim parametro1 As New ParameterDiscreteValue
        Dim parametro2 As New ParameterDiscreteValue
        parametro1.Value = HF1.Value
        parametro2.Value = HF2.Value
        rpt.Load(Publico.RutaRpt & "RptListado.rpt")
        'rpt.ParameterFields(0).CurrentValues.Add(parametro1)
        'rpt.ParameterFields(1).CurrentValues.Add(parametro2)
        rpt.SetDataSource(dt)
        rpt.SetParameterValue(0, HF2.Value)
        rpt.SetParameterValue(1, HF1.Value)
        'CR1.ReportSource = rpt
        'rpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, True, "C:\Partida")
        rpt.PrintToPrinter(1, True, 1, 1)
    End Sub

    Protected Sub LinkButton3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton3.Click
        Dim obj As New Egresados
        Dim dt As DataTable = obj.GetListaEgresados(HF1.Value, HF2.Value)
        Dim rpt As New ReportDocument
        rpt.Load(Publico.RutaRpt & "RptListado.rpt")
        rpt.SetDataSource(dt)
        rpt.SetParameterValue(0, HF3.Value)
        rpt.SetParameterValue(1, HF1.Value)
        rpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, True, "Listado")
    End Sub

    Protected Sub LinkButton4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton4.Click
        Dim obj As New Egresados
        Dim dt As DataTable = obj.GetListaEgresados(HF1.Value, HF2.Value)
        Dim rpt As New ReportDocument
        rpt.Load(Publico.RutaRpt & "RptListado.rpt")
        rpt.SetDataSource(dt)
        rpt.SetParameterValue(0, HF3.Value)
        rpt.SetParameterValue(1, HF1.Value)
        rpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.Excel, Response, True, "Listado")
    End Sub

    Protected Sub LinkButton5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton5.Click
        Dim obj As New Egresados
        Dim dt As DataTable = obj.GetListaEgresados(HF1.Value, HF2.Value)
        Dim rpt As New ReportDocument
        rpt.Load(Publico.RutaRpt & "RptListado.rpt")
        rpt.SetDataSource(dt)
        rpt.SetParameterValue(0, HF3.Value)
        rpt.SetParameterValue(1, HF1.Value)
        rpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.WordForWindows, Response, True, "Listado")
    End Sub
End Class
